package com.teamin.web.controller;

import com.teamin.service.INetDiskService;
import com.teamin.service.ProgressService;
import com.teamin.vo.CircleLabelsVO;
import com.teamin.vo.CircleProgressSecondVO;
import com.teamin.vo.CircleProgressVO;
import com.teamin.vo.NetDiskFoldersByParentIdVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: yangrui
 * @Description: 进展(含部分文档)
 * @Date: 上午10:33 2017/11/24
 */
@Api(description = "v0.12 进展(含部分文档)")
@RestController
@RequestMapping(value = "/v1/circle")
public class ProgressController {

    @Autowired
    private INetDiskService netDiskService;

    @Autowired
    private ProgressService progressService;

    /**
     * @Author: yangrui
     * @Description: 根据节点显示文件夹列表
     * @Date: 上午10:59 2017/11/24
     */
    @ApiOperation(value = "根据节点显示文件夹列表")
    @GetMapping(value = "/{circleId:\\d+}/foldersByParentId")
    public List<NetDiskFoldersByParentIdVO> foldersByParentId(@RequestAttribute("loginUserId") @ApiParam(hidden = true) Long loginUserId,
                                                              @ApiParam(value = "圈子ID", required = true) @PathVariable Integer circleId,
                                                              @ApiParam(value = "文件夹节点，根为固定值0", required = true) @RequestParam Long parentId) {
        return netDiskService.foldersByParentId(loginUserId, circleId, parentId);
    }

    /**
     * @Author: yangrui
     * @Description: 文件移动至
     * @Date: 上午10:34 2017/11/24
     */
    @ApiOperation(value = "文件移动至")
    @PostMapping(value = "/{circleId:\\d+}/fileMove")
    public void fileMove(@RequestAttribute("loginUserId") @ApiParam(hidden = true) Long loginUserId, @ApiParam(value = "圈子ID", required = true) @PathVariable Integer circleId,
                         @ApiParam(value = "文件/文件夹唯一IDs，逗号隔开", required = true) @RequestParam String fileIds,
                         @ApiParam(value = "移动至文件夹节点，根为固定值0", required = true) @RequestParam Long parentId) {
        netDiskService.fileMove(loginUserId, circleId, fileIds, parentId);
    }


    /**
     * @Author: yangrui
     * @Description: 查看圈子所有任务的标签
     * @Date: 上午10:35 2017/11/24
     */
    @ApiOperation(value = "查看圈子所有任务的标签")
    @GetMapping(value = "/{circleId:\\d+}/labels")
    public List<CircleLabelsVO> labels(@RequestAttribute("loginUserId") @ApiParam(hidden = true) Long loginUserId, @ApiParam(value = "圈子ID", required = true) @PathVariable Integer circleId) {

        return progressService.labels(loginUserId, circleId);
    }

    /**
     * @Author: yangrui
     * @Description: 进展
     * @Date: 上午10:36 2017/11/24
     */
    @ApiOperation(value = "进展")
    @GetMapping(value = "/{circleId:\\d+}/progress")
    public CircleProgressVO progress(@RequestAttribute("loginUserId") @ApiParam(hidden = true) Long loginUserId, @ApiParam(value = "圈子ID", required = true) @PathVariable Integer circleId, @ApiParam(value = "标签Ids，逗号隔开") String labelIds) {

        return progressService.progress(loginUserId, circleId, labelIds);
    }
}
